<?
class AcIndexAction{
	
	public $smarty;
	public $name;
    public $openid;
    public $phone;
    public $js_sdk;
    private $model;

	//构造方法，初始化 
	public function __construct(&$_smarty,&$_js_sdk,&$_model) {
		$this->smarty = $_smarty;
        $this->js_sdk = $_js_sdk;
        $this->model = $_model;
	}

    /**
     * 显示页面
     */
	public function action(){
        if(!empty($this->name)){
            $this->smarty->assign('name',$this->name);
        }
        if(!empty($this->openid)){
            $this->smarty->assign('openid',$this->openid);
        }
        if(!empty($this->js_sdk)){
            $signPackage = $this->js_sdk->GetSignPackage();
            $this->smarty->assign('appId',$signPackage["appId"]);
            $this->smarty->assign('timestamp',$signPackage["timestamp"]);
            $this->smarty->assign('nonceStr',$signPackage["nonceStr"]);
            $this->smarty->assign('signature',$signPackage["signature"]);
        }
		$this->smarty->display('templates/ac_index.tpl');
	}

    /**
     * 存在openid
     * @param $name
     * @param $phone
     * @param $openid
     */
    public function existsOpenid(&$openid){
        $this->model->openid = $openid;
        return $this->model->checkUserToOpenid();
    }

    /**
     * 分享
     */
    public  function  share(){

    }
	
}